﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ElectronicJournal.DB;
using ElectronicJournal.DB.Item;

namespace ElectronicJournal
{
    public partial class ViewNews : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                int idNews = Convert.ToInt32(Request["idNews"]);
                if (idNews > 0)
                {
                    DbNews dbNews = new DbNews();
                    ItemNews news = dbNews.GetNews(idNews);

                    lblTitle.Text = news.title;
                    lblContent.Text = news.content;
                    lblDate.Text = news.date.ToString();

                    if (System.Web.HttpContext.Current.User.IsInRole("Administrator"))
                    {
                        aEdit.NavigateUrl = "~/Admin/News.aspx?idNews=" + news.idNews.ToString();
                        aEdit.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("./Default.aspx");
            }
        }
    }
}